﻿@model ZhongheCms.Models.GswTblBaseInfo
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
 var strChk = "";
    if (Model.NewFlag > 0)
    {
        strChk = "checked";
    }
}
@section css{
    <link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="/Assets/webuploader/webuploader.css" />

}<div class="row">
    <div class="col-xs-12 col-sm-12 widget-container-col">
        @using (Html.BeginForm("Create", "BaseInfo", new { id = Model.Id, ViewBag.m, ViewBag.f, ViewBag.p, ViewBag.fid,ViewBag.r }, FormMethod.Post,
            new { name = "myForm", id = "myForm", @class = "form-horizontal", role = "form" }))
        {
            <div class="widget-box">
                <div class="widget-header">
                    <h5 class="widget-title">@ViewBag.f  @if (!string.IsNullOrEmpty(ViewBag.p))
                                                         {
                            <span>(@ViewBag.p)</span>
                                                         }</h5>

                    <div class="widget-toolbar">
                    </div>
                </div>

                <div class="widget-body">


                    <div class="widget-main">

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="TypeNo">序号</label>

                            <div class="col-sm-9">
                                <input type="text" id="TypeNo" name="TypeNo" placeholder="排列序号" value="@Model.TypeNo"  class="col-xs-10 col-sm-5" data-val="true" data-val-number="排列序号为非法的数字格式" data-val-regex="排列序号为非法的数字格式"
                            data-val-regex-pattern="^(-?\d+)(\.\d+)?$" data-val-required="排列序号为非法的数字格式" />
                             <span class="field-validation-valid help-block" data-valmsg-for="TypeNo" data-valmsg-replace="true"></span>   
                            </div>
                        </div>

                        <div class="hr hr-2 dotted"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="MasterType">名称</label>

                            <div class="col-sm-9">
                                <input type="text" id="MasterType" name="MasterType" placeholder="@ViewBag.f" value="@Model.MasterType" class="col-xs-10 col-sm-5"  data-val="true" data-val-required="字段不允许为空"  />
                                <span class="field-validation-valid help-block" data-valmsg-for="MasterType" data-valmsg-replace="true"></span>
                            </div>
                        </div>
                        <div class="hr hr-2 dotted"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="NewFlag">首页显示</label>

                            <div class="col-sm-9">
                                <input type="checkbox" id="NewFlag" name="NewFlag"  value="1"  @strChk/>
                            </div>
                        </div>
                        <div class="hr hr-2 dotted"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" >图片</label>

                            <div class="col-sm-9">
                               <img width="200" height="100" alt="200x100" id="img" src="@Model.TypePic" />


                                            <div class="btns" style="margin-top: 5px">
                                                <div id="picker">
                                                    点击选择图片
                                                </div>

                                            </div>
                                            <input type="hidden" id="TypePic" name="TypePic" value="@Model.TypePic" />
                            </div>
                        </div>
                        <div class="hr hr-2 dotted"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="Remark">描述</label>

                            <div class="col-sm-9">
                                <textarea id="Remark" name="Remark" class="form-control" style="height: 200px">@Model.Remark</textarea>
                            </div>
                        </div>


                        @if (ViewBag.scode == "1")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-ok"></i>
                                    提示信息
                                </strong>

                                信息保存成功!
																
                            </div>
                        }
                        @if (ViewBag.scode == "0")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-danger">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-remove"></i>
                                    错误提示
                                </strong>

                                @Html.ValidationSummary(true)

                            </div>

                        }
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-check bigger-110"></i>
                                    保存&nbsp;&nbsp;
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="button" onclick="funBack()">
                                  &nbsp;&nbsp;<i class="ace-icon fa fa-undo bigger-110"></i>
                                        返回&nbsp;&nbsp;
                                </button>
                            </div>
                        </div>




                    </div>



                </div>

            </div>
        }

    </div>


</div>
@section js{
     <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.bootstrap.js"></script>
   
    <script charset="utf-8" src="/kindeditor/kindeditor-min.js" type="text/javascript"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
    <script src="/Assets/webuploader/webuploader.js" type="text/javascript"></script>
    <script type="text/javascript">
        KindEditor.ready(function (K) {
           
            

        });
        jQuery(function ($) {
            //$('.datepick').datepicker({ autoclose: true, format: "yyyy-mm-dd", language: "zh-CN" });


            var uploader = WebUploader.create({

                resize: true,

                // 自动上传。
                auto: true,

                // swf文件路径
                swf: '/Assets/webuploader/Uploader.swf',

                // 文件接收服务端。
                server: '/GsnService/UploadFileToQiniu/',

                // 选择文件的按钮。可选。
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: '#picker'
            });

               // 当有文件添加进来的时候
               //uploader.on('fileQueued', function (file) {
               //    $list.append('<div id="' + file.id + '" class="item">' +
               //    '<h4 class="info">' + file.name + '</h4>' +
               //    '<p class="state">等待上传...</p>' +
               //    '</div>');
               //});

               // 文件上传过程中创建进度条实时显示。
               uploader.on('uploadProgress', function (file, percentage) {
                   var $li = $('#' + file.id),
               $percent = $li.find('.progress .progress-bar');
                   // 避免重复创建
                   if (!$percent.length) {
                       $percent = $('<div class="progress progress-striped active">' +
                       '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                       '</div>' +
                       '</div>').appendTo($li).find('.progress-bar');
                   }
                   $li.find('p.state').text('上传中');

                   $percent.css('width', percentage * 100 + '%');
               });
               uploader.on('uploadSuccess', function (file) {
                   $('#' + file.id).find('p.state').text('已上传');
               });
               uploader.on('uploadError', function (file) {
                   $('#' + file.id).find('p.state').text('上传出错');
               });
               // 完成上传完了，成功或者失败，先删除进度条。
               uploader.on('uploadComplete', function (file) {
                   $('#' + file.id).find('.progress').fadeOut();
                   //alert(file.name);
               });

               //获取返回值
               uploader.on('uploadAccept', function (file, response) {
                   //response.FileName
                   //  $('#fName').val(response.FileName);
                   $('#TypePic').val(response.SavePath + response.SaveName);
                   $('#img').attr("src", response.SavePath + response.SaveName);
               });

           });
        function funBack() {
            document.location = "/BaseInfo/Index/0?m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&r=@ViewBag.r";
        }

    </script>
}